{-
   The prime factors of 13195 are 5, 7, 13 and 29.
   What is the largest prime factor of the number 600851475143 ?
-}

number = 600851475143

prime [] = []
prime (x:xs)
	|x == 1 = prime xs
	|otherwise = x: prime [a|a<-xs,a `mod` x /= 0]

largestprimefactor [] = error "are you kidding, it is an empty list!!!"
largestprimefactor (x:xs)
	|number `mod` x == 0 = x
	|otherwise = largestprimefactor xs

lastvalue = largestprimefactor(reverse(prime [1..(number `div` 2)]))

isprime::Integer->Bool  
isprime n
	|n<=1 = False
	|cannotdivideeach n [2..sqrt n] = True
	|otherwise = False
	where 

cannotdivideeach n (x:xs)
	|null xs = True
	|otherwise = if n `mod` x == 0 then False else cannotdivideeach n xs

